﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Data;
using ClassLibrary.Entity;

public partial class Admin_ListAccounts : AdminPage
{
    TblAccountsDAO AccountDAO = new TblAccountsDAO(Global.CONNECTION_STRING);
    TblAlbumImagesDAO AlbumDAO = new TblAlbumImagesDAO(Global.CONNECTION_STRING);
    TblImagesDAO ImageDAO = new TblImagesDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            string IDAl = Request.QueryString["IDAl"];
            if (IDAl != null || IDAl != "")
            {
                DataTable dt = AlbumDAO.GetAlbumsById(Convert.ToInt32(IDAl));
                foreach (DataRow dr in dt.Rows)
                {
                    lblAlbumName.Text = dr["AlbumName"].ToString();
                }
                LoadListAlbum();
                LoadImageByIDAl();
                pnImage.Visible = true;
            }
            else
            {
                LoadListAlbum();
                pnImage.Visible = false;
            }
        }
    }

    private void LoadImageByIDAl()
    {
        string IDAl = Request.QueryString["IDAl"];
        reImage.DataSource = ImageDAO.GetImageByIdAlbum(Convert.ToInt32(IDAl));
        reImage.DataBind();
    }

    private void LoadListAlbum()
    {
        grdListAlbum.DataSource = AlbumDAO.GetAlbumsByIDAcc(0);
        grdListAlbum.DataBind();
    }
    protected void btnUpdate_Click(object sender, ImageClickEventArgs e)
    {
        int IDLayout = Convert.ToInt32(((ImageButton)sender).CommandArgument);
        Response.Redirect("~/Admin/ListAlbums.aspx?IDAl=" + IDLayout);
    }
    protected void grdListAlbum_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdListAlbum.PageIndex = e.NewPageIndex;
        LoadListAlbum();
    }
}
